//tooltip

$(document).ready(function(){
	$('[data-tooltip]').addClass('tooltip');
	$('.tooltip').each(function() {  
		$(this).append('<span class="tooltip-content">' + $(this).attr('data-tooltip') + '</span>');  
	});
	
	if ($.browser.msie && $.browser.version.substr(0,1)<7)
	{
	  $('.tooltip').mouseover(function(){
			$(this).children('.tooltip-content').css('visibility','visible');
		  }).mouseout(function(){
			$(this).children('.tooltip-content').css('visibility','hidden');
		  });
	}
});

//search box toggle

function hide(id)
{/*
	 $(".drop").click(function(e) {
            		e.stopPropagation();
					});
	$(document).click(function() {
					if (!$(".drop").is(':hidden')){
            		$('.drop').hide();
					}
        			});
if ($('#'+id).is(':hidden')){
                	$('#'+id).show();
				}
            	else{
                	$('#'+id).hide();
            	}*/
				// $(".drop").hide();
$('#'+id).toggle();	

}


//Javascript for Add dynamic text box on button click
var m=0,k=0,l=0;
function insert(limit,inputname,divid ){
	my_div=document.getElementById(divid);
	 var newTBDiv = document.createElement("div");
	 newTBDiv.innerHTML = "<input type='text' name='"+inputname+"'>";
	if(divid=="mandskills"){
		
	if(k<limit)  {
		 my_div .appendChild(newTBDiv);
		  k++;
	 }
	}else if(divid=="preferskills"){
		if(m<limit)  {
	  		
		 my_div .appendChild(newTBDiv);
		  m++;
	 }
	}else if(divid=="avoidskills"){
		if(l<limit)  {
			
		 my_div .appendChild(newTBDiv);
		  l++;
	 }
	}
}

// Scroll to top
$(document).ready(function() {
	// Check to see if the window is top if not then display button
	$(window).scroll(function() {
		if ($(this).scrollTop() > 100) {
			$('.scrollToTop').fadeIn();
		} else {
			$('.scrollToTop').fadeOut();
		}
	});
	// Click event to scroll to top
	$('.scrollToTop').click(function() {
		$('html, body').animate({
			scrollTop : 0
		}, 800);
		return false;
	});
});



// Read more in info box
$(document).ready(function() {
	  $('.nav-toggle').click(function(){
		//get collapse content selector
		var collapse_content_selector = $(this).attr('href');					

		//make the collapse content to be shown or hide
		var toggle_switch = $(this);
		$(collapse_content_selector).toggle(function(){
		  if($(this).css('display')=='none'){
                            //change the button label to be 'Show'
			toggle_switch.html('Read More');
		  }else{
                            //change the button label to be 'Hide'
			toggle_switch.html('Hide');
		  }
		});
	  });

	});	

//login pop up
$(document).ready(function() {
	$('a.login-window').click(function() {
		
		// Getting the variable's value from a link 
		var loginBox = $(this).attr('href');

		//Fade in the Popup and add close button
		$(loginBox).fadeIn(300);
		
		//Set the center alignment padding + border
		var popMargTop = ($(loginBox).height() + 24) / 2; 
		var popMargLeft = ($(loginBox).width() + 24) / 2; 
		
		$(loginBox).css({ 
			'margin-top' : -popMargTop,
			'margin-left' : -popMargLeft
		});
		
		// Add the mask to body
		$('body').append('<div id="mask"></div>');
		$('#mask').fadeIn(300);
		
		return false;
	});
	
	// When clicking on the button close or the mask layer the popup closed
	$('a.close, #mask').live('click', function() { 
	  $('#mask , .login-popup').fadeOut(300 , function() {
		$('#mask').remove();  
	}); 
	return false;
	});
});//end of login pop up